clear textprogressbar; clear;
%% Create session, Connect devices
[session, zi]=CreateSession;
plt = zi.plotterModule;

%% 
plt.reset();
plt.subscribeChannel('0', {'x', 'r', 'phase'});
plt.subscribeChannel('1', {'phase'});
plt.subscribeChannel('3', {'theta'});
% plt_data = plt.run('window_time', 10.0, 'total_duration', 3.0);
% plt_data = plt.run('window_time', 10.0, 'total_duration', 3.0, 'plotter_hdl', 'none');
plt_data = plt.run('window_time', 10.0, 'total_duration', 3.0, 'processMonitor', @new_plot);
plt.unsubscribeChannel();

%%
figure('Name', 'Plotter data');
plt_data_0x = plt_data.getNodeData('0', 'x');
plot(plt_data_0x.time, plt_data_0x.value);

%%
function new_plot(obj, ~, data)
    for k=1:length(obj.curves)
        obj.curves(k).XData = data(k).time - max(data(k).time);
        obj.curves(k).YData = 100*data(k).value;
    end
    drawnow limitrate
end